package com.jack006.api.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @Classname Swagger3Configuration
 * @Description Swagger3配置类
 * @Date 2021-06-12 09:47
 * @Created by jack
 */
@Configuration
public class Swagger3Configuration {

    //    http://localhost:8088/swagger-ui/index.html     路径

    // 配置swagger2核心配置 docket
    @Bean
    public Docket createRestApi() {

        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("600客街新闻·自媒体接口api")                       // 文档页标题
                .contact(new Contact("600客街",
                        "https://www.jack006.com",
                        "1324672259@qq.com"))                   // 联系人信息
                .description("专为新闻·自媒体平台提供的api文档")      // 详细信息
                .version("1.0.1")                               // 文档版本号
                .termsOfServiceUrl("https://www.jack006.com")     // 网站地址
                .build();
    }
}
